//
//  EditPwdApi.m
//  EMMApp
//
//  Created by Mac on 16/5/24.
//  Copyright © 2016年 YiXun. All rights reserved.
//

#import "EditPwdApi.h"
#define myUrlMethod @"editPwd"
#define myUrlPath @"/appapi/editPwd"
@implementation EditPwdApi
{
    NSString *_body;
}
- (instancetype)initWithMerchantId:(NSString *)merchantId
                            userId:(NSString *)userId
                             token:(NSString *)token
                          loginPwd:(NSString *)loginPwd
                            newPwd:(NSString *)newPwd {
    self = [super init];
    if (self) {
        NSMutableDictionary *params = [NSMutableDictionary dictionary];
        [params setValue:apiVersion forKey:@"version"];
        [params setValue:[IDTools devId2] forKey:@"terminalCode"];
        [params setValue:merchantId forKey:@"merchantId"];
        [params setValue:userId forKey:@"userId"];
        [params setValue:token forKey:@"token"];
        [params setValue:loginPwd forKey:@"loginPwd"];
        [params setValue:newPwd forKey:@"newPwd"];
        _body = [@{@"params" : params} JSONString];
        NSLog(@"%@:\n %@%@?body=%@", myUrlMethod, apiBaseUrl, myUrlPath, _body);
    }
    return self;
}

#pragma mark - 父类继承拓展

- (NSString *)requestUrl
{
    return myUrlPath;
}

- (id)requestArgument
{
    return @{ @"body" : _body };
}

- (NSString *)methodString
{
    return myUrlMethod;
}


#pragma mark - 通用

- (EditPwd *)resultData
{
    id myObj = [IDTools jsonStrToObjc:self.responseString method:myUrlMethod];
    
    EditPwd *data = (EditPwd *)myObj;
    
    NSLog(@"%@ resultData is %@", myUrlMethod, data);
    
    return data;
}

- (BOOL)isSuccess
{
    NSString *str = [[self resultData] result];
    if ([NSString isStringEmpty:str] || ![str isEqualToString:@"1"]) {
        return NO;
    } else {
        return YES;
    }
}

@end
